package com.tornado.community.interceptor;

import com.tornado.community.provider.Tools;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    private final Tools tools;

    public WebConfig(Tools tools) {
        this.tools = tools;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new SessionInterceptor(tools))
                .addPathPatterns("/**")
                .excludePathPatterns("/static/**")
                .excludePathPatterns("/")
                .excludePathPatterns("/callback")
                .excludePathPatterns("/question/**")
                .excludePathPatterns("/force/**");
    }
}
